<template>
<view class="full-fix-page">
	<view v-if="show" class="picker-bottom-wrap customer-date-wrap a-fadeinB">
		<view class="picker-hd">
			<view class="cancle f-blue" @click="cancel">{{$t('package_member.cancel')}}</view>
			<view class="confirm f-blue" @click="confirm">{{$t('package_member.confirm')}}</view>
		</view>
		<picker-view :indicator-style="indicatorStyle" :value="value" class="picker-view-wrap row-3" @change="changeDate">
			<picker-view-column class="item-column">
				<view class="item" v-for="(item,index) in years" :key="index">{{item}}</view>
			</picker-view-column>
			<picker-view-column class="item-column">
				<view class="item" v-for="(item,index) in months" :key="index">{{item}}</view>
			</picker-view-column>	
			<picker-view-column class="item-column">
				<view class="item" v-for="(item,index) in days" :key="index">{{item}}</view>
			</picker-view-column>
		</picker-view> 
	</view>
</view>
</template>

<script> 
export default{
	name:'demo',
	data(){
		const date = new Date()
		const years = []
		const year = date.getFullYear()
		const months = []
		const month = date.getMonth() + 1
		const days = []
		const day = date.getDate()
		for (let i = 1990; i <= date.getFullYear(); i++) {
			years.push(i)
		}
		for (let i = 1; i <= 12; i++) {
			months.push(i)
		}
		for (let i = 1; i <= 31; i++) {
			days.push(i)
		} 
		return{
			years,
			year,
			months,
			month,
			days,
			day,
			indicatorStyle: `height: 40px;line-height:40px;`,
			value: [9999, month-1, day-1],
			date:"",
		}
	}, 
	props:{
		dateType:{
			type:String
		},
		show:{
			type:Boolean
		}
	},
	mounted() { 
	},
	methods:{
		// 取消选择
		cancel(){
			this.$emit('cancel',false)
		},
		
		confirm(){ 
			this.$emit('confirm',{
				type:this.dateType,
				date:this.date
			})
		},
		
		// 选择日期
		changeDate(e){ 
			this.value=e.detail.value;
			this.date=this.years[this.value[0]]+'-'+this.months[this.value[1]]+'-'+this.days[this.value[2]]; 
		}
	},
	 
}
</script>

<style lang="less">
 
</style>
